<?php
/*
 * 作者：*****
 * 内容：投诉表
 */
namespace App\model;

use Illuminate\Database\Eloquent\Model;

class Complaints extends Model
{
    protected $table="complaints";

    /*
     * 作者：*****
     * 内容：查询所有的投诉信息
     */
    public function selectComplaints()
    {
        return $this
            ->select('j.use_name as j_name','s.use_name as s_name','j.use_num','s.use_card','com_case')
            ->join('user as j','j.use_id','=','complaints.com_use_id')
            ->join('user as s','s.use_id','=','complaints.com_stu_id')
            ->orderBy('com_time','desc')
            ->paginate(2)
            ->toArray();
    }
    /*
     * 作者：*****
     * 内容：根据教练ID查询教练的投诉信息
     */
    public function selectCoaComplaints($id)
    {
        return $this
            ->select('j.use_name as j_name','s.use_name as s_name','j.use_num','s.use_card','com_case')
            ->join('user as j','j.use_id','=','complaints.com_use_id')
            ->join('user as s','s.use_id','=','complaints.com_stu_id')
            ->where('com_use_id',$id)
            ->orderBy('com_time','desc')
            ->paginate(2)
            ->toArray();
    }
}
